const initCycleTLS = require('cycletls');
// Typescript: import initCycleTLS from 'cycletls';

(async () => {
    // Initiate CycleTLS
    const cycleTLS = await initCycleTLS();
    // Send request
    var CCC = 0;
    for(var page = 1;page<101;page++) {
        const response = await cycleTLS.get('https://api.investing.com/api/financialdata/historical/1156681?start-date=2022-05-11&end-date=2023-05-11&time-frame=Weekly&add-missing-rows=false', {
            // body: 'page=' + String(page) + '',
            headers: {
                'authority': 'api.investing.com',
                'accept': 'application/json, text/plain, */*',
                'accept-language': 'zh-CN,zh;q=0.9,th;q=0.8,en;q=0.7,or;q=0.6',
                'cache-control': 'no-cache',
                'domain-id': 'cn',
                'origin': 'https://cn.investing.com',
                'pragma': 'no-cache',
                'referer': 'https://cn.investing.com/',
                'sec-ch-ua': '"Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"',
                'sec-ch-ua-mobile': '?0',
                'sec-ch-ua-platform': '"Windows"',
                'sec-fetch-dest': 'empty',
                'sec-fetch-mode': 'cors',
                'sec-fetch-site': 'same-site',
                'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36',
                'Cookie': '__cf_bm=PGg4f8.ADG1nfWa_UbzoD9OM9DJxFcdXQC_taF5gtIs-1683788065-0-ARIh00f6Hf9KT7ZztPdOjoiP+GqTmLNo8n+MCIWSD5IuEub6P6fUFQWkXvFfbzMNAy8V08z8i55O570xLYHSpqY='
              },
            ja3: '771,35466-4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-21,29-23-24,0',
            userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36',
            // cookies:[{
            //     name: "sessionid",
            //     value: "vg7eb6ni418tpdoa5typqaymzvf0k2iu",
            //     expires: "Mon, 29-Jan-2022 15:04:05 EST",
            // }]
            timeout:15
        });
    console.log(response.body)

    
    };


    cycleTLS.exit();
})();